package com.firexxx.study.util.event;

import com.firexxx.study.util.UUIDUtil;
import lombok.Getter;
import org.springframework.context.ApplicationEvent;

import java.time.LocalDateTime;

/**
 * @description: TODO
 * @throws:
 * @author: zhuangzhang2
 * @date: 2019/12/17 11:07
 */
@Getter
public abstract class Event<T> extends ApplicationEvent {

    private static final long serialVersionUID = 4270583679213522514L;

    private String eventId;
    private LocalDateTime createDateTime;

    public Event(T source) {
        super(source);
        this.eventId = UUIDUtil.strings();
        this.createDateTime = LocalDateTime.now();
    }

    @Override
    public T getSource() {
        return (T)super.getSource();
    }
}